package model.persistencia.dao;

import java.util.HashMap;
import java.util.List;

import model.bean.Aluno;
import model.bean.Matricula;
import model.bean.Turma;

public class AlunoDAO extends GenericDAO<Aluno> {

	public AlunoDAO(Class persistentClass) {
		super(persistentClass);
	}

	public AlunoDAO(){
		super(Aluno.class);
	}
	
	public List<Aluno> getAlunosComIndicacao(Turma turma){
		String query = "SELECT a FROM "+Matricula.class.getName()+" AS m " +
				"INNER JOIN m.aluno  AS a INNER JOIN m.turma AS t " +
				"INNER JOIN m.indicacao as i " +
				"WHERE t.id = :turma";
		HashMap parametros = new HashMap();
		parametros.put("turma", turma.getId());
		
		return listar(query, parametros);
	}
	
	public List<Aluno> getAlunosSemIndicacao(Turma turma){
		String query = "SELECT a FROM "+Matricula.class.getName()+" AS m " +
				"INNER JOIN m.aluno  AS a INNER JOIN m.turma AS t " +
				"LEFT JOIN m.indicacao as i " +
				"WHERE t.id = :turma AND i.id is null";
		HashMap parametros = new HashMap();
		parametros.put("turma", turma.getId());
		
		return listar(query, parametros);
	}
}
